/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 *
 */

import { resolveHookDependency } from '../../../utils/task-util.js';
import { TaskNames } from '../../common/task-names.js';
import { ModuleTaskService } from '../../service/module-task-service.js';
import { TargetTaskService } from '../../service/target-task-service.js';
import { AbstractModuleHookTask } from '../abstract-module-hook-task.js';

/**
 * 预览方构建
 *
 * @since 2022/11/29
 */
export class PreviewBuild extends AbstractModuleHookTask {
  constructor(moduleTaskService: ModuleTaskService, isFaMode: boolean) {
    super(moduleTaskService, isFaMode, TaskNames.Task.PREVIEW_BUILD);
  }

  initTaskDepends(taskTargetService: TargetTaskService): void {
    const name: string = this._isFaMode ? 'LegacyPreviewCompileArkTS' : 'PreviewArkTS';
    this.dependsOn(resolveHookDependency(name, taskTargetService.getTargetData().getTargetName()));
  }
}
